import org.apache.commons.collections4.CollectionUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class IdSplit {

    public static void main(String[] args) throws IOException {
        File file = new File("G:\\GitLab\\group-core\\hx-all-in-one\\common\\target\\ams_1_id.txt");
        FileReader fileReader = new FileReader(file);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        String line;
        String lastLine = null;
        List<Long> idList = new ArrayList<>();
        int i = 0;
        while((line = bufferedReader.readLine()) != null){
            if(i%500 == 0){
                idList.add(Long.parseLong(line));
            }
            i++;
            lastLine = line;
        }
        if(Objects.nonNull(lastLine) && CollectionUtils.isNotEmpty(idList)
                && Long.parseLong(lastLine) != idList.get(idList.size() - 1)){
            idList.add(Long.parseLong(lastLine));
        }

        for(Long id: idList){
            System.out.println("id:" + id);
        }

        System.out.println("-------");

        if(idList.size()>1){
            for(int j = 1;j<idList.size();j++){
                if(j==idList.size()-1){
                    System.out.println((idList.get(j-1) - 1)+","+(idList.get(j)+1));
                }else {
                    System.out.println((idList.get(j-1) - 1)+","+(idList.get(j)));
                }
            }
        }

    }

}
